home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / update-manager / check-new-release
Text File  |  2009-11-02  |  2KB  |  50 lines

  1. #!/usr/bin/python2.6
  2.  
  3. import warnings
  4. warnings.filterwarnings("ignore", "apt API not stable yet", FutureWarning)
  5. import apt
  6. import time
  7. import sys
  8.  
  9. from DistUpgrade.utils import init_proxy
  10. from UpdateManager.Core.MetaRelease import MetaReleaseCore
  11. from optparse import OptionParser
  12. from gettext import gettext as _
  13.  
  14. RELEASE_AVAILABLE=0
  15. NO_RELEASE_AVAILABLE=1
  16.  
  17. if __name__ == "__main__":
  18.  
  19.   init_proxy()
  20.  
  21.   parser = OptionParser()
  22.   parser.add_option ("-d", "--devel-release", action="store_true",
  23.                      dest="devel_release", default=False,
  24.                      help=_("Check if upgrading to the latest devel release "
  25.                           "is possible"))
  26.   parser.add_option ("-p", "--proposed", action="store_true",
  27.                      dest="proposed_release", default=False,
  28.                      help=_("Try upgrading to the latest release using "
  29.                             "the upgrader from $distro-proposed"))
  30.   parser.add_option ("-q", "--quiet", default=False,
  31.                      dest="quiet", 
  32.                      help=_("Do not output anything, just return %s "
  33.                     "if there is a new release and %s "
  34.                 "if there is none.") % (RELEASE_AVAILABLE,
  35.                                                     NO_RELEASE_AVAILABLE))
  36.   (options, args) = parser.parse_args()
  37.   
  38.   # main work
  39.   m = MetaReleaseCore(useDevelopmentRelease=options.devel_release,
  40.                       useProposed=options.proposed_release)
  41.  
  42.   while m.downloading:
  43.     time.sleep(0.5)
  44.   if m.new_dist is not None:
  45.     if not options.quiet:
  46.       print _("New release '%s' available.") % m.new_dist.name
  47.       print _("Run 'do-release-upgrade' to upgrade to it.")
  48.       sys.exit(RELEASE_AVAILABLE)
  49.   sys.exit(NO_RELEASE_AVAILABLE)
  50.